import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '项目',
    align: "center",
    sorter: true,
    dataIndex: 'projectId_dictText'
  },
  {
    title: '项目简称',
    align: "center",
    sorter: true,
    dataIndex: 'projectShortName'
  },
  {
    title: '项目名',
    align: "center",
    sorter: true,
    dataIndex: 'projectName'
  },
  {
    title: '所属部门',
    align: "center",
    sorter: true,
    dataIndex: 'departId_dictText'
  },
  {
    title: '用户',
    align: "center",
    sorter: true,
    dataIndex: 'userId_dictText'
  },
  {
    title: '用户角色',
    align: "center",
    sorter: true,
    dataIndex: 'userRole_dictText'
  },
  {
    title: '状态',
    align: "center",
    sorter: true,
    dataIndex: 'userProjectStatus',
    customRender:({text}) => {
       return  render.renderSwitch(text, [{text:'是',value:'Y'},{text:'否',value:'N'}]);
     },
  },
  {
    title: '创建人',
    align: "center",
    sorter: true,
    dataIndex: 'createBy'
  },
  {
    title: '创建时间',
    align: "center",
    sorter: true,
    dataIndex: 'createTime'
  },
  {
    title: '更新人',
    align: "center",
    sorter: true,
    dataIndex: 'updateBy'
  },
  {
    title: '更新时间',
    align: "center",
    sorter: true,
    dataIndex: 'updateTime'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "项目",
    field: 'projectId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tm_project,project_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "项目简称",
    field: 'projectShortName',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "项目名",
    field: 'projectName',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "所属部门",
    field: 'departId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "sys_depart,depart_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "用户",
    field: 'userId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "sys_user where status='1',realname,username"
    },
    //colProps: {span: 6},
  },
  {
    label: "用户角色",
    field: 'userRole',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tm_project_user_role,role_name,role_code"
    },
    //colProps: {span: 6},
  },
  {
    label: "状态",
    field: 'userProjectStatus',
    component: 'JSwitch',
    componentProps:{
    },
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '项目',
    field: 'projectId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tm_project,project_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入项目!'},
             ];
    },
  },
  {
    label: '所属部门',
    field: 'departId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "sys_depart,depart_name,id"
    },
  },
  {
    label: '用户',
    field: 'userId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "sys_user where status='1',realname,username"
    },
  },
  {
    label: '用户角色',
    field: 'userRole',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tm_project_user_role,role_name,role_code"
    },
  },
  {
    label: '状态',
    field: 'userProjectStatus',
    component: 'JSwitch',
    componentProps:{
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  projectId: {title: '项目',order: 0,view: 'list', type: 'string',dictTable: "tm_project", dictCode: 'id', dictText: 'project_name',},
  projectShortName: {title: '项目简称',order: 1,view: 'text', type: 'string',},
  projectName: {title: '项目名',order: 2,view: 'text', type: 'string',},
  departId: {title: '所属部门',order: 3,view: 'list', type: 'string',dictTable: "sys_depart", dictCode: 'id', dictText: 'depart_name',},
  userId: {title: '用户',order: 4,view: 'sel_search', type: 'string',dictTable: "sys_user where status='1'", dictCode: 'username', dictText: 'realname',},
  userRole: {title: '用户角色',order: 5,view: 'list', type: 'string',dictTable: "tm_project_user_role", dictCode: 'role_code', dictText: 'role_name',},
  userProjectStatus: {title: '状态',order: 6,view: 'switch', type: 'string',},
  createBy: {title: '创建人',order: 7,view: 'text', type: 'string',},
  createTime: {title: '创建时间',order: 8,view: 'datetime', type: 'string',},
  updateBy: {title: '更新人',order: 9,view: 'text', type: 'string',},
  updateTime: {title: '更新时间',order: 10,view: 'datetime', type: 'string',},
};
